package com.diankangwo.service.impl;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.diankangwo.dao.PayResultDAO;
import com.diankangwo.domain.PayResult;
import com.diankangwo.service.PayResultService;
import com.diankangwo.util.PageSupport;

/***
 * @author songrongye PayResultService的实现类
 */
@Service(value = "payResultService")
public class PayResultServiceImpl implements PayResultService {
	@Autowired
	private PayResultDAO payResultDAO;

	/***
	 * @param
	 *            t 保存或者修改缴费结果
	 */
	@Override
	public void saveOrUpdate(PayResult t) {

		payResultDAO.saveOrUpdate(t);
	}

	/***
	 * 通过Id删除缴费结果
	 * 
	 * @param
	 *            id
	 * @return null;
	 */
	public boolean deleteById(int id) {
		if (id != 0) {
			payResultDAO.deleteById(id);
			return true;
		} else {
			return false;
		}
	}

	/***
	 * 分页查询缴费结果
	 * 
	 * @param pageNo
	 * @param pageSize
	 * @return List;
	 */
	@SuppressWarnings("rawtypes")
	public List findPage(int pageNo, int pageSize) {

		List<PayResult> list = payResultDAO.findList(pageNo, pageSize);
		return list;
	}

	/***
	 * 根据缴费编号查询缴费信息
	 * 
	 * @param billNo
	 * @return PayResult;
	 */
	@Override
	public PayResult queryByBillNo(String billNo) {
		if (billNo != null) {
			PayResult payResult = payResultDAO.queryByBillNo(billNo);
			return payResult;
		} else {
			return null;
		}
	}

	/***
	 * 根据ID查询
	 * 
	 * @param id
	 * @return PayResult
	 */
	@Override
	public PayResult queryById(int id) {
		if (id != 0) {
			PayResult payResult = payResultDAO.find(id);
			return payResult;
		} else {
			return null;
		}
	}

	/***
	 * 备用分页查询缴费结果
	 * 
	 * @param pageNo,pageSize
	 * @return PageSupport<PayResult>
	 */
	@Override
	public PageSupport<PayResult> findPagination(int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	/***
	 * 批量删除缴费结果
	 * 
	 * @param
	 * @return boolean
	 */
	@Override
	public boolean deletemore(Serializable[] args) {
		if (args.length != 0 && args != null) {
			payResultDAO.deleteByIds(args);
			return true;
		}
		return false;
	}

	/***
	 * @param
	 *            id 根据Id删除缴费结果
	 */
	@Override
	public void deleteById(Integer id) {
		try {
			payResultDAO.deleteById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/***
	 * 根据缴费日期查询
	 */
	@Override
	public List<PayResult> queryByTime(Date date) {
		if (date != null) {
			List<PayResult> payResults = payResultDAO.queryByTime(date);
			return payResults;
		}
		return null;
	}

	/***
	 * 查询所有的缴费结果
	 */
	@Override
	public List<PayResult> queryAll() {

		try {
			List<PayResult> payResults = payResultDAO.findAll();
			return payResults;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}
/***
 * 分页查询
 */

	@Override
	public List<PayResult> pageFind(int pageNo, int pageSize, Object... values) {
		String hql="";
		 List<PayResult>  payResults=payResultDAO.findPagination(hql, pageNo, pageSize, values).getResultData();
		 return payResults;
	}

	


	}


